package ${bao}.${controllerPackage};

import com.alibaba.fastjson.JSONObject;
import ${bao}.${entityPackage}.${entity};
import ${bao}.${servicePackage}.${entity}Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Map;

import java.util.List;

/**
* 描述: ${table.comment}
* author: ${author}
* date: ${date}
*/

@RestController
@RequestMapping(value="/${entity?lower_case}")
public class ${entity}Controller {

    @Autowired
    private ${entity}Service ${entity?lower_case}Service;

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public JSONObject add${entity?lower_case}(${entity} ${entity?lower_case}){
        return ${entity?lower_case}Service.add${entity?lower_case}(${entity?lower_case});
    }

    @RequestMapping(value="/list", method=RequestMethod.GET)
    public List<${entity}> list(){
        return ${entity?lower_case}Service.list();
    }

    @RequestMapping(value = "/list/{id}", method = RequestMethod.GET)
    public JSONObject listbyid(@PathVariable int id){
    return ${entity?lower_case}Service.listbyid(id);
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
    public JSONObject delete${entity?lower_case}(@PathVariable int id){
        return ${entity?lower_case}Service.delete${entity?lower_case}(id);
    }


    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public JSONObject update${entity?lower_case}(${entity} ${entity?lower_case}){
        return ${entity?lower_case}Service.update${entity?lower_case}(${entity?lower_case});
    }


}
